{% extends "xadmin/base_site.html" %}
{% load i18n %}
{% load url from future %}
{% load xadmin_tags %}
{% load crispy_forms_tags %}

{% block breadcrumbs %}
{% if account_view %}
<ul class="breadcrumb">
  <link href="/websys/static/xadmin/vendor/bootstrap-table/css/bootstrap-table.min.css" type="text/css" media="screen" rel="stylesheet" />
<li><a href="{% url 'xadmin:index' %}">{% trans 'Home' %}</a></li>
  <li class="active"> {{ title }} </li>
</ul>
{% else %}
<ul class="breadcrumb">
  <li><a href="{% url 'xadmin:index' %}">{% trans 'Home' %}</a></li>
  <li>
    {% if has_view_permission %}
    <a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a>
    {% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %}
  </li>
  <li><a href="{% url opts|admin_urlname:'change' original.pk %}">{{ original|truncatewords:"18" }}</a></li>
  <li class="active">{% trans 'Change password' %}</li>
</ul>
{% endif %}
{% endblock %}

{% block content-nav %}
{% endblock %}
{% block content %}
<!--页面设计在这儿....{{ serverval }}-->
    <style>
    .tb_tr{height: 50px; border:gainsboro 1px  double;}
    .tb_td{height: 50px; border: gainsboro 1px double; width:80px;}
    .td_info_1{background-color: #1da7ee;color: #0C0C0C;width: 100px; border:gainsboro 1px  double;}
    .td_info_2{width: 150px; border:gainsboro 1px  double;}
    .td_info_3{width: 300px; border:gainsboro 1px  double;}
    .txt_10{width: 300px;}
    .txt_20{width: 300px;}
    .txt_30{width: 300px;}
    .txt_40{width: 300px;}
    .td_title_1{font-weight: bold; font-size: 15px;}
    .tr_card_0{background-color: #1da7ee;}
    .tr_card_0 td{width: 80px;}
    .tb_normal{}
    .tb_normal td{border:gainsboro 1px  double;}
    </style>
    <table style="width: 100%">
        <tr class="tb_tr">
            <td class="tb_td">服务器：</td>
            <td>
                <select id="sel_pf">
                    <option value="" selected="selected">请选择</option>
                    {% for item in htmldata.apps %}
                            <option value="{{ item.pf }}">{{ item.name }}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
        <tr class="tb_tr">
            <td class="tb_td">档位：</td>
            <td>
                <select id="sel_dw">
                    <option value="" selected="selected">请选择</option>
                    {% for item in rechargedata.lists %}
                            <option value="{{ item.id }},{{ item.price }}">{{ item.name }}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
        <tr class="tb_tr" id="tr_uid" >
            <td class="tb_td">Uid：</td>
            <td><input type="text" maxlength="40" id="txt_uid" class="txt_30"><span>注:此项必填!</span></td>
        </tr>
        <!-- <tr class="tb_tr" id="tr_nickname" >
            <td class="tb_td">昵称：</td>
            <td><input type="text" maxlength="100" id="txt_nickname" class="txt_10" >
            </td>
        </tr>
        <tr class="tb_tr" id="tr_gold">
            <td class="tb_td">等级：</td>
            <td><input type="text" maxlength="100" id="txt_level" class="txt_10" ><span></span>
            </td>
        </tr>
        <tr class="tb_tr" id="tr_silver" >
            <td class="tb_td">经验：</td>
            <td><input type="text" maxlength="100" id="txt_exp" class="txt_10" ><span></span>
            </td>
        </tr>
        <tr class="tb_tr" id="tr_count" >
            <td class="tb_td">宝石：</td>
            <td><input type="text" maxlength="60" id="txt_gold" class="txt_30"><span></span></td>
            </td>
        </tr>
        <tr class="tb_tr" id="tr_stage" >
            <td class="tb_td">游戏金币：</td>
            <td><input type="text" maxlength="60" id="txt_silver" class="txt_30"><span></span></td>
        </tr>
        <tr class="tb_tr" id="tr_prestige" >
            <td class="tb_td">声望：</td>
            <td><input type="text" maxlength="60" id="txt_prestige" class="txt_30"><span></span></td>
        </tr>
        <tr class="tb_tr" id="tr_datafrom" >
            <td class="tb_td">VIP等级：</td>
            <td><input type="text" maxlength="100" id="txt_VIP_level" class="txt_10" ><span></span>
            </td>
        </tr>
        <tr class="tb_tr" id="tr_propids" >
            <td class="tb_td">VIP经验：</td>
            <td><input type="text" maxlength="40" id="txt_VIP_exp" class="txt_20"><span></span>
            </td>
            </td>
        </tr>
        <tr class="tb_tr" id="tr_hero_exp" >
            <td class="tb_td">武将经验：</td>
            <td><input type="text" maxlength="60" id="txt_hero_exp" class="txt_30"><span></span></td>
        </tr>
        <tr class="tb_tr" id="tr_task" >
            <td class="tb_td">武将碎片出售获得的灵魂数：</td>
            <td><input type="text" maxlength="60" id="txt_soul" class="txt_30"><span></span></td>
        </tr>
        <tr class="tb_tr" id="tr_task" >
            <td class="tb_td">装备碎片出售获得的矿石数：</td>
            <td><input type="text" maxlength="60" id="txt_piece_ore" class="txt_30"><span></span></td>
        </tr> -->
        <tr class="tb_tr">
            <td class="tb_td"></td>
            <td><label id="la_link"> {{links}}</label>&nbsp;&nbsp;<input type="button" id="bt_copy" value="确认" onclick="toSearch()"><span></span>
        </tr>
    <tr class="tb_tr">
            <td class="tb_td" colspan="2">
                <table data-toggle="table" data-height="100%"  data-pagination="true" id="table_report" style="">
                    <thead>
                        <tr>
                            <th  data-field="uids">UID*服务器</th>
                            <th  data-field="moeny">充值金额</th>
                            <th  data-field="charge_id">档位</th>
                            <th  data-field="times">充值时间</th>
<!--                             <th  data-field="type">类型</th>
                            <th  data-field="point">游戏币</th>
                            <th  data-field="gold">金币</th>
                            <th  data-field="stage">关卡</th>
                            <th  data-field="task">任务</th> -->
                        </tr>
                    </thead>
                </table>
            </td>
    </tr>
    </table>
    <script type="text/javascript" src="/websys/static/xadmin/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script src="/websys/static/xadmin/vendor/bootstrap-datepicker/js/locales/bootstrap-datepicker.zh-CN.js"></script>
    <script src="/websys/static/xadmin/vendor/bootstrap-table/js/bootstrap-table.min.js"></script>
    <script src="/websys/static/xadmin/vendor/bootstrap-table/js/bootstrap-table-locale-all.min.js"></script>
    <script>
    //查询
    // var dic3 = {};
    // $.getJSON("/websys/static/gamejson/currency.json", function (data) {
    //     dic3[1] = data;
    // })
    // $.getJSON("/websys/static/gamejson/hero.json", function (data) {
    //     dic3[2] = data;
    // })
    // $.getJSON("/websys/static/gamejson/equipment.json", function (data) {
    //     dic3[3] = data;
    // })
    // $.getJSON("/websys/static/gamejson/item.json", function (data) {
    //     dic3[5] = data;
    // })
    function toSearch()
    {   
    //     function contains(arr, obj) {  
    //     var i = arr.length;  
    //     while (i--) {  
    //         if (arr[i] === obj) {  
    //             return true;  
    //         }  
    //     }  
    //     return false;  
    // }
        //var list3 =[0,1,2,3,5];
        var recharge_id=$('#sel_dw').val();
        var uid=$('#txt_uid').val();
        var server=$('#sel_pf').val();
        // var txt_gold=$('#txt_gold').val();
        // var txt_silver=$('#txt_silver').val();
        // var level=$('#txt_level').val();
        // var exp=$('#txt_exp').val();
        // var prestige=$('#txt_prestige').val();
        // var VIP_level=$('#txt_VIP_level').val();
        // var VIP_exp=$('#txt_VIP_exp').val();
        // var hero_exp=$('#txt_hero_exp').val();
        // var soul=$('#txt_soul').val();
        // var piece_ore=$('#txt_piece_ore').val();
        
        if(uid==''||recharge_id==''){
            alert('UID或档位不能空！');
            return;
        }
        // else{
        //     if(txt_gold==''&& txt_silver==''&&nickname==''&&level==''&&exp==''&&prestige==''&&VIP_level==''&&VIP_exp==''&&hero_exp==''&&soul==''&&piece_ore==''){
        //     alert('不能都为空!');
        //     return;
        // }
        // }
        if (server ==''){
                alert('服务器不能为空!');
                return;
            }
        // }
        // if (VIP_level !=''){
        //     if(Number(VIP_level) >20){
        //         alert('VIP等级不能大于20!');
        //         return;
        //     }
        // }

    
    if(confirm("是否确认充值？")) {
    $.post('/xadmin/ajax_userdata/re_recharges/', {"uid":uid,"recharge_id":recharge_id,'server':server}, function(result){
            //alert(result.ret);
            if(result.ret == 0)
            {
                    //console.log($(id).attr('serverip'))
                    alert(result.msg + "("+result.ret +")")
                    window.location.reload();
            }else
            {
                alert(result.msg + "("+result.ret +")")
            }
         }, "json")

    }
        
    
}

    function querset()
    {   
        //alert('ssss');
        //alert(t0+"-"+t1+"开发中。"+t2);//data-url="/websys/static/data2.txt"
        var turl='/xadmin/ajax_userdata/qu_recharges';//?date='+t0+','+t1+'&type='+t2;
        $('#table_report').bootstrapTable('destroy'); // 显示之前，先把当前表格销毁
        $('#table_report').bootstrapTable({
            //search: true,
            locale:'zh-CN',//中文支持
            sortable: true,      //是否启用排序
            //showFooter:true,
            sortName:'date',
            //showRefresh: true,
            pagination: true,//是否开启分页（*）
             pageNumber:1,//初始化加载第一页，默认第一页
             pageSize: 10,//每页的记录行数（*）
              pageList: [10,20,50],//可供选择的每页的行数（*）
            method: "get",         // 经过测试，只有post方法能发给后端的helloWorld.do
            showExport: true,                     //是否显示导出
            exportDataType: "basic",              //basic', 'all', 'selected'.
            //sidePagination: 'server',
            queryParamsType:'', //默认值为 'limit' ,在默认情况下 传给服务端的参数为：offset,limit,sort
　　// 设置为 ''  在这种情况下传给服务器的参数为：pageSize,pageNumber
            queryParams: function (params) {
                return {
                    //meterID: $('#meterid').val(),
                    pageSize: params.pageSize,
                    //offset: params.offset,
                    pageNumber:params.pageNumber,
                    sortOrder: params.order,
                    sort: params.sort, //排序列名
                }
            },

            url:turl,   // 发送到后端helloWorld.do，由helloWorld.do返回json字符串，
                                    // 必须是列表形式，例如：[{"name":"aaa","id":"kkk"},{...},...]

        });
    }
querset()
    </script>
{% endblock %}